<!--
 *
 * FaZend Framework
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt. It is also available 
 * through the world-wide-web at this URL: http://www.fazend.com/license
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@fazend.com so we can send you a copy immediately.
 *
-->

<?php
    $this->includeCSS('units.css');

    $this->includeJQuery();
    $this->includeJS('units.js');

    $this->headTitle('units');
?>

<div class="wrapper">

    <?php $latest = ''; ?>

    <?php foreach ($this->tests as $test): ?>

        <?php foreach (($sectors = array_slice(explode('/', $test), 0, -1)) as $id=>$sector): ?>

            <?php $title = implode('/', array_slice($sectors, 0, $id+1)); ?>

            <?php if (strpos($latest, $title) !== false) continue; ?>

            <span style="margin-left: <?php echo substr_count($title, '/') * 20?>px;"><?php echo $sector?></span>
            <br/>

        <?php endforeach; ?>

        <?php $md5 = 'x' . md5($test); ?>

        <span class="unit"
            style="margin-left: <?php echo substr_count($test, '/') * 20?>px;"
            id="<?php echo $md5?>"
            title="<?php echo $this->escape($test)?>"
            onclick="run($('#<?php echo $md5?>'), $('#log_<?php echo $md5?>'), '<?php echo $test?>');"
            ><?php echo $this->escape(ltrim(substr($test, strrpos($test, '/')), '/'))?></span>
            
        <span class="unitlog" 
            id="log_<?php echo $md5?>"
            onclick="stop('<?php echo $test?>');"
            title="stop it now"></span>

        <br/>

        <?php $latest = $test; ?>

    <?php endforeach; ?>

</div>

<div class="panel">
    <pre id="output"></pre>
    <pre id="protocol"></pre>
</div>

